﻿<Window x:Class="SeleniumRecorder.Loader"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:ctr="clr-namespace:LoadingPanelSample.Controls" 
        Icon="pack://application:,,,/Resources/favicon.ico" 
             xmlns:classicTheme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic"
        Title="Loader" Height="90" Width="300" WindowStartupLocation="CenterScreen" WindowStyle="None">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="bool2visibility" />

        <LinearGradientBrush x:Key="panelBackground" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="1" />
            <GradientStop Color="#FF1B1B1B" />
        </LinearGradientBrush>

        <Style x:Key="basicButton" TargetType="{x:Type Button}">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
            <Setter Property="BorderBrush" Value="{x:Static classicTheme:ClassicBorderDecorator.ClassicBorderBrush}" />
            <Setter Property="BorderThickness" Value="3" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Padding" Value="0,0,1,1" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <classicTheme:ClassicBorderDecorator x:Name="ContentContainer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" BorderStyle="None" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </classicTheme:ClassicBorderDecorator>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsKeyboardFocused" Value="True">
                                <Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedFocused"/>
                            </Trigger>
                            <Trigger Property="IsDefaulted" Value="True">
                                <Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedFocused"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedPressed"/>
                            </Trigger>
                            <Trigger Property="ToggleButton.IsChecked" Value="True">
                                <Setter Property="BorderStyle" TargetName="ContentContainer" Value="RaisedPressed"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="closeButton" BasedOn="{StaticResource basicButton}" TargetType="Button">
            <Setter Property="VerticalAlignment" Value="Top" />
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="9" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Margin" Value="15,7" />
            <Setter Property="Background" Value="{x:Null}" />
        </Style>

        <Style x:Key="panelMessageText" TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Margin" Value="0,11,0,0" />
            <Setter Property="TextWrapping" Value="WrapWithOverflow" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="FontSize" Value="16" />
            <Setter Property="VerticalAlignment" Value="Top" />
            <Setter Property="FontFamily" Value="Arial" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
        </Style>

        <Style x:Key="panelSubMessageText" TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Margin" Value="0,5" />
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="VerticalAlignment" Value="Top" />
            <Setter Property="FontFamily" Value="Arial" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
        </Style>
    </Window.Resources>

    <DockPanel Background="{StaticResource panelBackground}" 
             Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=IsLoading, Mode=OneWay, Converter={StaticResource bool2visibility}}">
        <Path Data="M0,44.956 L312.00641,44.956" Height="1" Margin="0,0.25,0,0" Stretch="Fill" DockPanel.Dock="Top" Stroke="Black" />
        <Path Data="M0,44.956 L312.00641,44.956" Height="1" Margin="0,0.25,0,0" Stretch="Fill" DockPanel.Dock="Top" Stroke="#FF2F2F2F" />

        <Button x:Name="btnClose"
            DockPanel.Dock="Right"
            Style="{StaticResource closeButton}"
            ToolTip="Close"
            Click="btnClose_Click_1"
            Content="Close X" />

        <ctr:CircularProgressBar x:Name="progressBar"
                             DockPanel.Dock="Left"
                             HorizontalAlignment="Left"
                             VerticalAlignment="Top"
                             Height="45"
                             Margin="18,10" />

        <StackPanel VerticalAlignment="Top">
            <TextBlock x:Name="txtMessage"
                 Style="{StaticResource panelMessageText}" 
                 Text="Please wait" 
                 Foreground="#FFA1C3D2" />

            <TextBlock x:Name="txtSubMessage"
                 Style="{StaticResource panelSubMessageText}" 
                 Text="Idtentifying controls.." 
                 Foreground="#FFA1C3D2" />
        </StackPanel>
    </DockPanel>
</Window>
